﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EFFC.Net.Parameters;

namespace EFFC.Net.ResourceLib.Parameters
{
    [Serializable]
    public class EmailParameter:ParametersStd
    {
        public EmailParameter()
        {
            this.AddPElement("From");
            this.AddPElement("User");
            this.AddPElement("Pass");
            this.AddPElement("To");
            this.AddPElement("Subject");
            this.AddPElement("Body");
            this.AddPElement("smtpServer");
            this.AddPElement("EncodingString", typeof(Encoding));
            this.AddPElement("IsBodyHTML", typeof(bool));
            AddPElement("Attachs", typeof(EmailAttachCollection));

            BodyEncoding = Encoding.UTF8;
            SetValue("Attachs", new EmailAttachCollection());
            SetValue("IsBodyHTML", true);
        }
        /// <summary>
        /// EmailFrom  a@b.com
        /// </summary>
        public string From
        {
            get { return GetValue<string>("From"); }
            set { SetValue("From", value); }
        }
        /// <summary>
        /// 登錄帳戶
        /// </summary>
        public string User
        {
            get { return GetValue<string>("User"); }
            set { SetValue("User", value); }
        }
        /// <summary>
        /// 登錄密碼
        /// </summary>
        public string Pass
        {
            get { return GetValue<string>("Pass"); }
            set { SetValue("Pass", value); }
        }
        /// <summary>
        /// EmailTo  a@b.com
        /// </summary>
        public string To
        {
            get { return GetValue<string>("To"); }
            set { SetValue("To", value); }
        }
        /// <summary>
        /// EmailSubject 標題
        /// </summary>
        public string Subject
        {
            get { return GetValue<string>("Subject"); }
            set { SetValue("Subject", value); }
        }
        /// <summary>
        /// email正文
        /// </summary>
        public string Body
        {
            get { return GetValue<string>("Body"); }
            set { SetValue("Body", value); }
        }
        /// <summary>
        /// smtpServer
        /// </summary>
        public string smtpServer
        {
            get { return GetValue<string>("smtpServer"); }
            set { SetValue("smtpServer", value); }
        }
        
        /// <summary>
        /// 文字編碼，如UTF-8，big5等,預設值為 UTF-8。
        /// </summary>
        public Encoding BodyEncoding
        {
            get { return GetValue<Encoding>("EncodingString"); }
            set { SetValue("EncodingString", value); }
        }
        /// <summary>
        /// 要添加的附件集合
        /// </summary>
        public EmailAttachCollection Attachments
        {
            get { return GetValue<EmailAttachCollection>("Attachs"); }
        }
        /// <summary>
        /// Body是否采用HTML格式显示，默认为true
        /// </summary>
        public bool IsBodyHTML
        {
            set { SetValue("IsBodyHTML", value); }
            get { return GetValue<bool>("IsBodyHTML"); }
        }
    }
}
